package com.tmc.bean.common;

import com.alibaba.fastjson.JSON;

public class CommonResult {

	private boolean success;
	private String message;
	private Object obj;

	public CommonResult (boolean success, String message, Object obj){
		this.success = success;
		this.message = message;
		this.obj = obj;
	}
	
	public CommonResult(){}
	
	public String toJson(){
		return JSON.toJSONString(this);
	}
	
	public static CommonResult makeSuccess(){
		return new CommonResult(true, null, null);
	}
	
	public static CommonResult makeSuccess(String message){
		return new CommonResult(true, message, null);
	}
	
	public static CommonResult makeSuccess(String message, Object obj){
		return new CommonResult(true, message, obj);
	}
	
	public static CommonResult makeFail(String message){
		return new CommonResult(false, message, null);
	}
	
	public static CommonResult makeFail(String message, Object obj){
		return new CommonResult(false, message, obj);
	}
	
	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}
}
